﻿using System;

namespace HalconDotNet
{
	// Token: 0x0200009C RID: 156
	internal class HTupleHandle : HTupleImplementation
	{
		// Token: 0x06001FB7 RID: 8119 RVA: 0x000BA27C File Offset: 0x000B847C
		protected override Array CreateArray(int size)
		{
			HHandle[] array = new HHandle[size];
			for (int i = 0; i < size; i++)
			{
				array[i] = new HHandle();
			}
			return array;
		}

		// Token: 0x06001FB8 RID: 8120 RVA: 0x000BA2A5 File Offset: 0x000B84A5
		protected override void NotifyArrayUpdate()
		{
			this.h = (HHandle[])this.data;
		}

		// Token: 0x06001FB9 RID: 8121 RVA: 0x000BA2B8 File Offset: 0x000B84B8
		public HTupleHandle(HHandle h)
		{
			base.SetArray(new HHandle[]
			{
				new HHandle(h)
			}, false);
		}

		// Token: 0x06001FBA RID: 8122 RVA: 0x000BA2D8 File Offset: 0x000B84D8
		public HTupleHandle(HHandle[] h, bool copy)
		{
			if (copy)
			{
				HHandle[] array = new HHandle[h.Length];
				for (int i = 0; i < h.Length; i++)
				{
					array[i] = new HHandle(h[i]);
				}
				base.SetArray(array, false);
				return;
			}
			base.SetArray(h, false);
		}

		// Token: 0x06001FBB RID: 8123 RVA: 0x000BA321 File Offset: 0x000B8521
		public override HTupleElements GetElement(int index, HTuple parent)
		{
			return new HTupleElements(parent, this, index);
		}

		// Token: 0x06001FBC RID: 8124 RVA: 0x000BA32B File Offset: 0x000B852B
		public override HTupleElements GetElements(int[] indices, HTuple parent)
		{
			if (indices == null || indices.Length == 0)
			{
				return new HTupleElements();
			}
			return new HTupleElements(parent, this, indices);
		}

		// Token: 0x06001FBD RID: 8125 RVA: 0x000BA342 File Offset: 0x000B8542
		public override void SetElements(int[] indices, HTupleElements elements)
		{
			new HTupleElementsHandle(this, indices).setH(elements.HArr);
		}

		// Token: 0x1700009C RID: 156
		// (get) Token: 0x06001FBE RID: 8126 RVA: 0x000BA356 File Offset: 0x000B8556
		// (set) Token: 0x06001FBF RID: 8127 RVA: 0x000B9B31 File Offset: 0x000B7D31
		public override HHandle[] HArr
		{
			get
			{
				return this.h;
			}
			set
			{
				base.SetArray(value, false);
			}
		}

		// Token: 0x1700009D RID: 157
		// (get) Token: 0x06001FC0 RID: 8128 RVA: 0x000B8A9C File Offset: 0x000B6C9C
		public override HTupleType Type
		{
			get
			{
				return HTupleType.HANDLE;
			}
		}

		// Token: 0x06001FC1 RID: 8129 RVA: 0x000BA360 File Offset: 0x000B8560
		public override void Dispose()
		{
			for (int i = 0; i < base.Length; i++)
			{
				if (this.h[i] != null)
				{
					this.h[i].Dispose();
				}
			}
		}

		// Token: 0x06001FC2 RID: 8130 RVA: 0x000BA398 File Offset: 0x000B8598
		public override HHandle[] ToHArr()
		{
			HHandle[] array = new HHandle[this.iLength];
			this.CopyToHArr(array, 0);
			return array;
		}

		// Token: 0x06001FC3 RID: 8131 RVA: 0x000BA3BC File Offset: 0x000B85BC
		public override object[] ToOArr()
		{
			object[] array = new object[this.iLength];
			this.CopyToOArr(array, 0);
			return array;
		}

		// Token: 0x06001FC4 RID: 8132 RVA: 0x000BA3E0 File Offset: 0x000B85E0
		public override int CopyToHArr(HHandle[] dst, int offset)
		{
			for (int i = 0; i < this.iLength; i++)
			{
				dst[i + offset] = new HHandle(this.h[i]);
			}
			return this.iLength;
		}

		// Token: 0x06001FC5 RID: 8133 RVA: 0x000BA418 File Offset: 0x000B8618
		public override int CopyToOArr(object[] dst, int offset)
		{
			for (int i = 0; i < this.iLength; i++)
			{
				dst[i + offset] = new HHandle(this.h[i]);
			}
			return this.iLength;
		}

		// Token: 0x06001FC6 RID: 8134 RVA: 0x000BA44E File Offset: 0x000B864E
		public override int CopyFrom(HTupleImplementation impl, int offset)
		{
			return impl.CopyToHArr(this.h, offset);
		}

		// Token: 0x06001FC7 RID: 8135 RVA: 0x000BA460 File Offset: 0x000B8660
		protected override void StoreData(IntPtr proc, IntPtr tuple)
		{
			for (int i = 0; i < this.iLength; i++)
			{
				HalconAPI.HCkP(proc, HalconAPI.SetH(tuple, i, this.h[i]));
			}
		}

		// Token: 0x06001FC8 RID: 8136 RVA: 0x000BA498 File Offset: 0x000B8698
		public static int Load(IntPtr tuple, out HTupleHandle data)
		{
			int num = 2;
			int num2;
			HalconAPI.GetTupleLength(tuple, out num2);
			HHandle[] array = new HHandle[num2];
			for (int i = 0; i < num2; i++)
			{
				if (!HalconAPI.IsFailure(num))
				{
					num = HalconAPI.GetH(tuple, i, out array[i]);
				}
			}
			data = new HTupleHandle(array, false);
			return num;
		}

		// Token: 0x0400118A RID: 4490
		protected HHandle[] h;
	}
}
